df_model = data.frame(
f2 = (train$f2== 11), 
f4 = (train$f4== 7900),
f67 = (train$f67>=10.47),
f68 = (train$f68 == 30),
f90 = (train$f90 >= 1.80),
f93 = as.factor(train$f93),
f103 = (train$f103==1),
loss=ifelse(train$loss>0,1,0)
)

m = glm(loss~., data=df_model, family=quasibinomial)

quantile(predict(m, type="response"), seq(.1, .99, .01))

for(i in 2:779){
a = train[,i]
a[is.na(train[,i])] = mean(train[!is.na(train[,i]),i])
qtiles = unique(quantile(a, seq(0, 1, .05)))
if(length(qtiles)>=2) 
{
	x = cut(a, qtiles,  include.lowest=T)
	v = tapply(ifelse(train$loss>0, 1, 0), x, mean)
	if(max(v)>.155) cat("f", i,"\t", max(v), "\n")
}
}

for(i in 2:779){
a = train[,i]
a[is.na(train[,i])] = mean(train[!is.na(train[,i]),i])
q99 = quantile(a, .99)
if(mean(train$loss[a>=q99])>1.2) print(i-1)
}
